def findkth(nums, k):
    ...
    if nums == []:
        return -1
    left = 0
    right = len(nums) - 1
    while left < right:
        pivot = quick_select(nums, left, right)
        if pivot == k - 1:
            return nums[pivot]
        elif pivot < k - 1:
            left = pivot + 1
        else:
            right = pivot


def quick_select(nums, left, right):
    ...
    tmp_value = nums[0]
    max_pointer = left + 1
    min_pointer = left + 1
    while min_pointer <= right:
        if nums[min_pointer] > tmp_value:
            nums[min_pointer], nums[max_pointer] = nums[max_pointer], nums[min_pointer]
            max_pointer += 1
        min_pointer += 1
    max_pointer -= 1
    nums[left], nums[max_pointer] = nums[max_pointer], nums[left]
    print(nums[:])
    return max_pointer


nums = [2, 1, 3, 7, 6, 0]

k = 1
print(findkth(nums, k))
